package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.mapper.UserMapper;
import com.hopu.blb_erp.entity.User;
import com.hopu.blb_erp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByName(String username) {
        return userMapper.selectByName(username);
    }

    @Override
    public User findById(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public List<User> find() {
        return userMapper.select();
    }

    @Override
    public void modify(User user) {
        User user1 = userMapper.selectById(user.getId());
        if(user1.isState()){
            user.setState(false);
        }else {
            user.setState(true);
        }
        userMapper.update(user);
    }

    @Override
    public Integer findCount() {
        return userMapper.selectCount();
    }

    @Override
    public List<User> findPage(Integer current, Integer pageSize) {
        return userMapper.selectPage(current, pageSize);
    }
}
